﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.Admin.Sys.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="Menu" TagName="Header" Src="~/Modules/Menu/Header.ascx" %>
<%@ Register TagPrefix="Menu" TagName="Footer" Src="~/Modules/Menu/Footer.ascx" %>
<%@ Register TagPrefix="Menu" TagName="SystemLeft" Src="~/Modules/Menu/SystemLeft.ascx" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/screen.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/main.css" />

    <script type="text/javascript" src="../js/Extend.js"></script>

    <script type="text/javascript" src="../js/Common.js"></script>

    <script type="text/javascript" src="../js/jquery-vsdoc.js"></script>

</head>
<body>
    <div class="container">
        <Menu:Header ID="Header1" runat="server" />
        <Menu:SystemLeft ID="menu_SystemLeft" runat="server" />
        <div class="span-20 last">
            <div id="userAdd" class="boxc">
                <div class="boxc">
                    <input type="text" id="txtUser" /><input type="button" id="btnFind" value="查找员工"
                        onclick="findEmployees()" /></div>
                <div id="employeeList" class="boxc">
                </div>
            </div>
            <div id="userList" class="boxc">
                数据加载中...</div>
        </div>
        <Menu:Footer ID="Footer1" runat="server" />
    </div>
</body>

<script type="text/javascript">
    function getSysUsers() {
        $.post("SysUser.ashx", { t: 1 }, function(data) {
            if (data.success == true) {
                $("#userList").html(data.message);
            }
            else {
                $("#userList").html("数据获取失败，请尝试刷新页面");
            }
        }, "json");
    }

    function findEmployees() {
        var p = {};
        p.t = 2;
        p.userName = jDoc("txtUser").value;
        $.post("SysUser.ashx", p, function(data) {
            if (data.success == true) {
                $("#employeeList").html(data.message);
            } else {
                jDoc("#employeeList").innerHTML = "获取数据失败";
            }
        }, "json");
    }

    function addSysUser(btn) {
        var uid = btn.id.replace("btn_", "");
        var p = {};
        var app = jDoc("sel_Website_" + uid);
        p.appId = app.options[app.selectedIndex].value;
        p.empId = uid;
        p.userName = jDoc("#ln_" + uid).value;
        p.password = jDoc("#pwd_" + uid).value;
        if (p.password.trim() == "") {
            alert("请输入密码");
            return;
        }
        p.t = 3;
        $.post("SysUser.ashx", p, function(data) {
            if (data.success == true) {
                getSysUsers();
                $("#employeeList").html("用户添加成功！为了访问某些页面，你可能还需要为该用户设置权限。");
            }
        }, "json");
    }

    function deleteSysUser(id) {
        if (confirm("确认删除吗？")) {
            $.post("SysUser.ashx", { id: id, t: 4 }, function(data) {
                if (data.success == true) {
                    alert("操作成功！");
                    getSysUsers();
                }
            }, "json");
        }
    }

    getSysUsers();
</script>
